package signRecord

import (
	"api/internal/svc"
	"api/internal/types"
	"context"
	"user_srv/userclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetContinuousSignDaysLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetContinuousSignDaysLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetContinuousSignDaysLogic {
	return &GetContinuousSignDaysLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetContinuousSignDaysLogic) GetContinuousSignDays(req *types.GetContinuousSignDays) (resp *types.Response, err error) {
	continuousDays, err := l.svcCtx.UserRpc.GetBitmapContinuousDays(l.ctx, &userclient.GetBitmapContinuousDaysRequest{ //获取连续签到天数
		UserId: int64(req.UserId),
	})
	if err != nil {
		return &types.Response{
			Code:    400,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Code:    200,
		Message: "获取连续签到天数成功",
		Data:    continuousDays.Days,
	}, nil
}
